package com.woniuxy.globalexceptionhandler;

import com.woniuxy.exception.BuildingInsertException;
import com.woniuxy.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result HandleException(Exception e){
        e.printStackTrace();
        return Result.failed().msg(e.getMessage());
    }

    @ExceptionHandler(BuildingInsertException.class)
    public Result HandleException(BuildingInsertException e){
        e.printStackTrace();
        return Result.failed().msg(e.getMessage());
    }
}
